package com.wg.photo.activity;

import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.wg.photo.ABSOnItemClickListener;
import com.wg.photo.BaseActivity;
import com.wg.photo.R;
import com.wg.photo.adapter.PickListAdapter;
import com.wg.photo.utils.PickConfig;

public class PickListActivity extends BaseActivity {
    private RecyclerView mRVlist;
    private PickListAdapter mAdapter;

    @Override
    public int getLayoutId() {
        return R.layout.activity_pick_list;
    }

    @Override
    public void initViews() {
        mRVlist = (RecyclerView) findViewById(R.id.act_choose_picture_RV_list);
    }

    @Override
    public void setListeners() {
        mRVlist.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false));
        mAdapter = new PickListAdapter(this,null);
        mRVlist.setAdapter(mAdapter);
        mAdapter.setAbsOnItemClickListener(new ABSOnItemClickListener() {
            @Override
            public void onItemClick(View v, int position) {
                String dirName = (String) v.getTag(R.id.pick_dir_name);
                Intent intent = new Intent();
                intent.setClass(PickListActivity.this, ChoosePictureActivity.class);
                intent.putExtra(PickConfig.INTENT_DIR_NAME, dirName);
                PickListActivity.this.setResult(PickConfig.LIST_PHOTO_DATA, intent);
                PickListActivity.this.finish();
            }
        });
    }
}
